package StudyCode.summary.mydatetime;

import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
import java.time.temporal.ChronoUnit;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CalculateNextBirthday {
	public static void main(String[] args) {
		LocalDate birthday = LocalDate.of(1999, Month.NOVEMBER, 1);
		LocalDate today = LocalDate.now();
		LocalDate nextBDay = birthday.withYear(today.getYear());
		if (nextBDay.isBefore(today) || nextBDay.isEqual(today)) {
			nextBDay = nextBDay.plusYears(1);
		}

		Period p = Period.between(today, nextBDay);
		long p2 = ChronoUnit.DAYS.between(today, nextBDay);
		System.out.println("还有" + p.getMonths() + "个月" + p.getDays() + "天过下一个生日，总共(" + p2 + ")天");
	}
}
